Skip to content

Conversation

@cadenmyers13
Copy link
Contributor

closes #8


print("Setting Q_damp and Q_broad to the refined values\n")
QDAMP_I = 0.045298
QBROAD_I = 0.016809
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user doesn't run the bulkNi script, the Qdamp and Qbroad values will be defined here. This is also needed to run tests (for now).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's see if we can fix this properly and not this ugly workaround.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbillinge To handle this, I had to add special handling for this script. I've pushed said special handling. Let me know if that looks okay.

@codecov
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.75%. Comparing base (6167dd9) to head (b8822b2).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #45       +/-   ##
===========================================
+ Coverage   50.00%   81.75%   +31.75%     
===========================================
  Files           2       11        +9     
  Lines          18     1211     +1193     
===========================================
+ Hits            9      990      +981     
- Misses          9      221      +212     
Files with missing lines Coverage Δ
.../ch03NiModelling/solutions/diffpy-cmi/fitBulkNi.py 97.54% <100.00%> (ø)
...es/ch03NiModelling/solutions/diffpy-cmi/fitNPPt.py 86.86% <100.00%> (ø)
...amples/ch05Fit2Phase/solutions/diffpy-cmi/fit2P.py 90.14% <100.00%> (ø)
...StructureGen/solutions/diffpy-cmi/fitCrystalGen.py 89.28% <100.00%> (ø)
...haseTransitions/solutions/diffpy-cmi/fitTSeries.py 89.85% <100.00%> (ø)
...ch08NPRefinement/solutions/diffpy-cmi/fitCdSeNP.py 89.07% <ø> (ø)
...s/ch11ClusterXYZ/solutions/diffpy-cmi/fitCdSeNP.py 90.24% <ø> (ø)
tests/conftest.py 66.66% <100.00%> (+30.95%) ⬆️
tests/test_examples.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cadenmyers13
Copy link
Contributor Author

cadenmyers13 commented Sep 22, 2025

@sbillinge ready for review.

Thanks for your help on this. I think this is nice and clean and it looks like the temp dir gets removed. Currently looking into ways of initializing the refinements with the refined values so this test runs quicker.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls see comments


# Change some style details of the plot
mpl.rcParams.update(mpl.rcParamsDefault)
if (PWD.parent.parent.parent / "utils" / "billinge.mplstyle").exists():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the group style added back in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbillinge I will have to add it to each file I think, I can do this!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better on another PR, but can we also do this work on the examples scripts also? Not just the solutions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbillinge Yeah I can do this. Do you want me to revert back then?


print("Setting Q_damp and Q_broad to the refined values\n")
QDAMP_I = 0.045298
QBROAD_I = 0.016809
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's see if we can fix this properly and not this ugly workaround.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls see comments

scripts = list(tmp_examples.rglob("**/solutions/diffpy-cmi/*.py"))
"""Run all example scripts to ensure they execute without error."""
# Run Ni example first to produce .res file
ni_script = list(tmp_examples.rglob("**/FitBulkNi.py"))[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to have turned something beautiful into something very ugly though. I think the figbulkNI runs first anyway so we probably don't need any of this. Do you want to have another crack at it, or should I try and see what I can come up with?

Also why are you recursively globbing a single file? I can see we need to work a bit on your coding skills......

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbillinge Let me give this another shot. Im just trying to figure out how to pull the results file from the temp dir.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice progress. Please see my comment. Looking much more in the right direction though..... I will wait for your next iteration.


# Change some style details of the plot
mpl.rcParams.update(mpl.rcParamsDefault)
if (PWD.parent.parent.parent / "utils" / "billinge.mplstyle").exists():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better on another PR, but can we also do this work on the examples scripts also? Not just the solutions?

@cadenmyers13
Copy link
Contributor Author

cadenmyers13 commented Sep 22, 2025

@sbillinge I figured out whats going on. rglob wasn't sorting the files in the right way so it was running PtNP example first so there was no file to grab the params from 🤦‍♂️ . I was racking my brain trying to figure out what was happening 😂 I'll make a push in a bit that should fix this.

@cadenmyers13
Copy link
Contributor Author

@sbillinge ready for review

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one last thing.

# sort list so that fitBulkNi.py runs first
scripts.sort(key=lambda s: 0 if s.name == "fitBulkNi.py" else 1)
for script in scripts:
script_relative_path = script.relative_to(tmp_examples).as_posix()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is your reason for the posix? this is likely to make it not work on windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbillinge This is to make it compatible across operating systems when converting the path to a string. Maybe it can go either way here (use str() or posix).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just delete it tbh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Will do

@cadenmyers13
Copy link
Contributor Author

@sbillinge responded to your comment

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

respond to comment

# sort list so that fitBulkNi.py runs first
scripts.sort(key=lambda s: 0 if s.name == "fitBulkNi.py" else 1)
for script in scripts:
script_relative_path = script.relative_to(tmp_examples).as_posix()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just delete it tbh

@cadenmyers13
Copy link
Contributor Author

@sbillinge Made the change. This test should pass in ~20 min.

@sbillinge sbillinge merged commit 656e3f3 into diffpy:main Sep 23, 2025
3 checks passed
@cadenmyers13 cadenmyers13 deleted the example-ci branch September 23, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create a test or few that will run a diffpy.cmi script in CI

2 participants